
/*
 * Hlpay-Plus aggregate payment system. Copyright
 * (c) 2022-2023 Hlpay Team Copyright has the right of final interpretation.
 */
package com.hlkj.pay.dto.admin;

import com.hlkj.framework.common.util.collection.CollectionUtils;
import com.hlkj.framework.common.util.json.JsonUtils;
import com.hlkj.pay.infrastructure.model.admin.AdminUserDO;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
 * @author HlpayTeam
 * @date 2024/09/02 10:02
 */
@Data
public class AdminUserDto extends AdminUserDO {
	/**
	 * 用户对应的权限数据
	 */
	private List<String> roleCodes;
	/**
	 * 用户对应的权限数据
	 */
	private List<String> partCodes;
	/**
	 * 用户对应的权限数据
	 */
	private List<String> roleNames;
	private String roleCodeStr;
	private List<String> partNames;
	private String partNameStr;
	private String roleNameStr;
	private String teamsName;
	
	
	private String email;
	private String phone;
	
	public List<String> getRoleCodes() {
		if(CollectionUtils.isNotEmpty(roleCodes)){
			return roleCodes;
		}
		if(!StringUtils.hasText(roleCodeStr)){
			return Collections.emptyList();
		}
		return Arrays.asList(roleCodeStr.split(","));
	}
	public List<String> getPartCodes() {
		if(CollectionUtils.isNotEmpty(partCodes)){
			return partCodes;
		}
		if(!StringUtils.hasText(getPartCode())){
			return Collections.emptyList();
		}
		return JsonUtils.parseArray(getPartCode(),String.class);
	}
	public List<String> getRoleNames() {
		if(CollectionUtils.isNotEmpty(roleNames)){
			return roleCodes;
		}
		if(!StringUtils.hasText(roleNameStr)){
			return Collections.emptyList();
		}
		return Arrays.asList(roleNameStr.split(","));
	}
}
